public class PositionNewEditOverrideExtension{
    
    // TODO: Declare a private variable of type Position__c called "pos".
    Position__c pos;
    Boolean bUpdate;
    // TODO: Declare a private Boolean variable called "bUpdate"
    //       to track if this is an insert or an update.

    // StandardController "controller" for later use in action methods.
    private ApexPages.StandardController controller;

    // String property to hold a message value
    public String myMessage { get; set; }
	
    // TODO: Declare the constructor for this class, which will be passed a
    //       reference to StandardController.
    //       Set the class member variable "controller" to the passed reference.
    //       Using a method on the reference to the passed StandardController, 
    //       obtain the position record and assign it to "pos".
    //       Set bUpdate according to whether an insert or an update is required.
    // HINT: The position's Id value can be used determine whether 
    //       an insert or update is required.
    
    
    public PositionNewEditOverrideExtension(ApexPages.StandardController stdcontroller)
    {
    	controller=stdcontroller;
    	pos=(Position__c)stdcontroller.getRecord();
    	bUpdate=(pos.Id==null?false:true);
    }
    // This function is called from a commandButton on the page
    public PageReference SayHelloWorld(){
        // call this custom function from your visualforce page
        myMessage = 'Hello World!';

        // We're not redirecting the user to a different page so we just say return null
        return null;
    }
    
		//TODO: Create a new action method called "mySave".  
		//      Add the conditional logic to do an insert or update, based on
		//      the flag set in the constructor.
    //      Return a PageReference by instantiating it and initializing it with
    //      a partial URL based on the position Id.
   public Pagereference mySave()
   {
   	if(bUpdate)
   	{
   		update pos;
   	}
   	else
   	{
   		insert pos;
   	}
   	PageReference p=new PageReference('/'+pos.Id);
   	return p;	
   }
}